<extend name="public:base" />
<block name="h-block">

</block>
<block name="breadcrumb">
    <ul class="breadcrumb">
        <li>
            <i class="ace-icon fa fa-book"></i>
            <a href="index">{:L('首页')}</a>
        </li>
        <li class="">{:L('权限管理')}</li>
        <li class="active">{:L('配置权限')}</li>
    </ul>
</block>
<block name="c-block">
    <link rel="stylesheet" href="__PLUGINS__/zTree/css/zTreeStyle.css" type="text/css">

<div class="main-content">
    <div class="row">
        <div class="app-list app-100">
            <div class="page-header">
                <h1>
                    配置权限
                    <small>
                        <i class="ace-icon fa fa-angle-double-right"></i>
                        请选择下面权限列表，分配角色行为权限
                    </small>
                </h1>
            </div>
            <form class="form-horizontal" action="{:U('groupSetaccess')}" method="post" role="form" id="card-info-form">
            <input type="hidden" name="grou_id" id="_grouid" value="{$group_id}" />
                <div class="row" align="">
                    <div class="col-xs-12">

                       <ul id="treeDemo" class="ztree"></ul>
                        

                        

                     <div class="col-sm-10">
                        <button class="btn btn-info " id="_submit" type="button" data-form="#card-info-form">
                            <i class="ace-icon fa fa-check bigger-110"></i>
                            {:L('保存')}
                        </button>
                        

                    </div>
            </form>
        </div>
    </div>
</div>
    </div>
    </div>
    </div>
              
        </div>
    </div>
</div>
</block>
<block name="f-block">
    <script src="__PLUGINS__/zTree/js/jquery.ztree.core.min.js"></script>
    <script src="__PLUGINS__/zTree/js/jquery.ztree.excheck.min.js"></script>
    <script type="text/javascript">
        var setting = {
        check:{enable: true},
        view: {showLine: false, showIcon: false, dblClickExpand: false},
        data: {
            simpleData: {enable: true, pIdKey:'pid', idKey:'id'},
            key:{name:'title'}
        }
    };
    var zNodes ={$data};
    function setCheck() {
        var zTree = $.fn.zTree.getZTreeObj("treeDemo");
        zTree.setting.check.chkboxType = { "Y":"ps", "N":"ps"};

    }
    $.fn.zTree.init($("#treeDemo"), setting, zNodes);
    setCheck();
    $("#_submit").click(function(){
        var _this = $(this);
        if(_this.hasClass("disabled")){
            return false;
        }
        var treeObj=$.fn.zTree.getZTreeObj("treeDemo"),
            nodes=treeObj.getCheckedNodes(true),
            v="";
        for(var i=0;i<nodes.length;i++){
            v+=nodes[i].id + ",";
        }
        var _form = $(_this.attr('data-form'));
        _this.addClass("disabled");
        $.post(_form.attr('action'),{'group_id':$("#_grouid").val(),'rules':v},function(rel){
            _this.removeClass('disabled');
            if(rel.code>0){
                if(rel.msg!=''){
                    success(rel.msg);
                }
            }else{
                error(rel.msg);
            }
            if(rel.url != '' && rel.url != undefined){
                setTimeout(function(){
                    if(rel.url == '/reload'){
                        top.location.reload();
                    }else{
                        location.href = rel.url;
                    }
                },2000);
            }
        })
    })
    </script>
</block>
